Ubuntu 14.04
Sponsored Link

OpenStack Icehouse : Add Images
2014/05/13
 
Add Virtual Machine images in Glance.
[1] Load environment variables first.
root@dlp:~#
unset SERVICE_TOKEN

root@dlp:~#
unset SERVICE_ENDPOINT

root@dlp:~#
vi ~/keystonerc
export OS_USERNAME=admin
export OS_PASSWORD=adminpassword
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://10.0.0.30:35357/v2.0/
export PS1='\u@\h \W(keystone)\$ '
root@dlp:~#
chmod 600 ~/keystonerc

root@dlp:~#
source ~/keystonerc

root@dlp ~(keystone)#
echo "source ~/keystonerc " >> ~/.bash_profile
# confirm status (it's OK if no errors are shown)

root@dlp ~(keystone)#
glance image-list
+----+------+-------------+------------------+------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+----+------+-------------+------------------+------+--------+
+----+------+-------------+------------------+------+--------+
[2] For example, Create a Virtual Machine image of Ubuntu 14.04 for adding.
# create a directory for disk image

root@dlp ~(keystone)#
mkdir -p /var/kvm/images
# create a disk image

root@dlp ~(keystone)#
qemu-img create -f qcow2 /var/kvm/images/ubuntu1404.img 10G
# install

root@dlp ~(keystone)#
virt-install \
--name Ubuntu1404 \
--ram 2048 \
--disk path=/var/kvm/images/ubuntu1404.img,format=qcow2 \
--vcpus=2 \
--os-type linux \
--os-variant=ubuntutrusty \
--graphics none \
--console pty,target_type=serial \
--location='http://jp.archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/' \
--extra-args='console=ttyS0,115200n8 serial'
Starting install...
# installation starts
[3]
After installation, change settings in virtual machine like follows and shutdown it.
* Install openssh-server.
* Remove /etc/udev/rules.d/70-persistent-net.rules if it exists
[4] Add the virtual image to Glance.
root@dlp ~(keystone)#
glance image-create --name="Ubuntu14.04" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/ubuntu1404.img

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 44ffa719f36f2ce553972c1f00d68eb5     |
| container_format | bare                                 |
| created_at       | 2014-05-05T05:21:38                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | e797ffd6-4d70-46b3-821b-abf1f8044f0c |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu14.04                          |
| owner            | fa66398ac25943629877cc6e459d38ae     |
| protected        | False                                |
| size             | 2040594432                           |
| status           | active                               |
| updated_at       | 2014-05-05T05:21:49                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+

root@dlp ~(keystone)#
glance image-list

+-----------+-------------+-------------+------------------+------------+--------+
| ID        | Name        | Disk Format | Container Format | Size       | Status |
+-----------+-------------+-------------+------------------+------------+--------+
| e797ffd6- | Ubuntu14.04 | qcow2       | bare             | 2040594432 | active |
+-----------+-------------+-------------+------------------+------------+--------+
[5] By the way, if you got an image fron internet, it's OK to simplt add it like follows.
root@dlp:~#
wget http://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
root@dlp:~#
glance image-create --name="Ubuntu1404" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | b65cbc63bfa4abb6144dddf43caa6b5e     |
| container_format | bare                                 |
| created_at       | 2014-05-05T05:26:46                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | 90b2b3fd-d671-4f2f-aba1-b8a890857bd8 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu1404                           |
| owner            | fa66398ac25943629877cc6e459d38ae     |
| protected        | False                                |
| size             | 252707328                            |
| status           | active                               |
| updated_at       | 2014-05-05T05:26:49                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+
 
Tweet